home *** CD-ROM | disk | FTP | other *** search
- /*
- File: History.c
-
- Copyright (c) 1990, Thomas Knoll.
- Copyright (c) 1993-6, Adobe Systems Incorporated.
- All rights reserved.
-
- C source file for History export example.
- */
-
- #if __MWERKS__
- #include <SetupA4.h> // A4-globals
- #include <A4Stuff.h> // A4-globals
- #endif
-
- #if defined(THINK_C) || defined(__MWERKS__)
- #define ENTRYPOINT main
- #endif
-
- #include "History.h"
-
- Handle hDllInstance = NULL;
-
- /*****************************************************************************/
-
- void InitGlobals (GPtr globals);
- void DoAbout (GPtr globals);
- void DoPrepare (GPtr globals);
- void DoStart (GPtr globals);
- void DoContinue (GPtr globals);
- void DoFinish (GPtr globals);
-
- /*****************************************************************************/
-
- /* All calls to the plug-in module come through this routine. It must be
- placed first in the resource. To achieve this, most development systems
- require that this be the first routine in the source. */
-
- #if MSWindows
- void ENTRYPOINT (short selector,
- ExportRecord *exportParamBlock,
- long *data,
- short *result)
- #else
- pascal void ENTRYPOINT (short selector,
- ExportRecord *exportParamBlock,
- long *data,
- short *result)
- #endif
- {
-
- Globals globalValues;
- GPtr globals = &globalValues;
-
- #if __MWERKS__
- EnterCodeResource(); // A4-globals
- #endif
-
- if (!*data)
- {
-
- InitGlobals (globals);
-
- *data = (long) NewHandle (sizeof (Globals));
-
- if (!*data)
- {
- *result = memFullErr;
- return;
- }
-
- ** (GHdl) *data = globalValues;
-
- }
-
- globalValues = ** (GHdl) *data;
-
- gStuff = exportParamBlock;
- gResult = noErr;
-
- switch (selector)
- {
-
- case exportSelectorAbout:
- DoAbout (globals);
- break;
-
- case exportSelectorPrepare:
- DoPrepare (globals);
- break;
-
- case exportSelectorStart:
- DoStart (globals);
- break;
-
- case exportSelectorContinue:
- DoContinue (globals);
- break;
-
- case exportSelectorFinish:
- DoFinish (globals);
- break;
-
- default:
- gResult = exportBadParameters;
- }
-
- *result = gResult;
- ** (GHdl) *data = globalValues;
-
- #if __MWERKS__
- ExitCodeResource(); // A4-globals
- #endif
-
- }
-
- /*****************************************************************************/
-
- void InitGlobals (GPtr globals)
- {
- gCurrentHistory = 1;
- }
-
- /*****************************************************************************/
-
- /* Prepare to export an image. If the plug-in module needs only a limited
- amount of memory, it can lower the value of the 'maxData' field. */
-
- void DoPrepare (GPtr globals)
- {
-
- gStuff->maxData = 0;
-
- }
-
- /*****************************************************************************/
-
- void GetHistory (GPtr globals, int16 index, Str255 s)
- {
- int16 currentResources = CountPIResources(histResource);
-
- s[ (s[0]=0) + 1] = 0;
-
- if (currentResources >= index)
- {
- Handle h = GetPIResource (histResource, index);
- if (h != NULL) PIHandle2String(h, s);
- // just a read-only reference. Do NOT dispose.
- }
- }
-
- /*****************************************************************************/
-
- /* Requests pointer to the first part of the image to be filtered. */
-
- void DoStart (GPtr globals)
- {
- short doThis = true;
-
- if (!WarnResourceProcsAvailable ())
- {
- gResult = errPlugInHostInsufficient;
- return;
- }
-
- gQueryForParameters = ReadScriptParams (globals);
-
- if ( gQueryForParameters ) doThis = DoParameters (globals);
-
- if ( doThis == false ) ; // user cancelled, etc.
-
- }
-
- /*****************************************************************************/
-
- /* Filters the area and requests the next area. */
-
- void DoContinue (GPtr globals)
- {
- }
-
- /*****************************************************************************/
-
- /* This routine will always be called if DoStart does not return an error
- (even if DoContinue returns an error or the user aborts the operation).
- This allows the module to perform any needed cleanup. None is required
- in this example. */
-
- void DoFinish (GPtr globals)
- {
- WriteScriptParams(globals);
- }
-
- /*****************************************************************************/
-